/**  
 * All rights Reserved, Designed By Android_Robot   
 * @Title:  MemberManageActivity.java   
 * @Package com.jiyi.activity.zone   
 * @Description:    TODO(用一句话描述该文件做什么)   
 * @author: HYM     
 * @date:   2017-7-20 下午2:00:51   
 * @version V1.0     
 */
package com.jiyi.activity.new_maintenance;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jiyi.adapter.CommonAdapter;
import com.jiyi.adapter.ViewHolder;
import com.jiyi.bean.zone.ZoneHaoYouBean;
import com.swift.base.ActivityBase;
import com.swift.maintenance.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @ClassName: MemberManageActivity
 * @Description:TODO(群组成员管理)
 * @author: HYM
 * @date: 2017-7-20 下午2:00:51
 * 
 */
public class JoinMemberReadActivity extends ActivityBase {

	@BindView(R.id.tvBack)
	TextView tvBack;
	@BindView(R.id.tvTitle)
	TextView tvTitle;
	@BindView(R.id.tvSearch)
	TextView tvSearch;

	/* activity控件 */
	@BindView(R.id.mainList)
	ListView mainList;

	// 数据适配器
	CommonAdapter<ZoneHaoYouBean> mAdapter;
	// 数据源
	List<ZoneHaoYouBean> dataList = new ArrayList<ZoneHaoYouBean>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_join_member_read);
		ButterKnife.bind(this);
		init();
	}

	private void init() {
		getIntentData();
		setTop();
		setAdapter();
	}

	/**
	 * @author: HYM
	 * @Title: getIntentData
	 * @Description: TODO(这里用一句话描述这个方法的作用) void
	 * @date: 2017-6-13
	 */
	private void getIntentData() {
		// 填充成员数据
		List<ZoneHaoYouBean> temp = new Gson().fromJson(getIntent()
				.getStringExtra("memberList"),
				new TypeToken<List<ZoneHaoYouBean>>() {
				}.getType());
		if (null != temp) {
			dataList.clear();
			dataList.addAll(temp);
		}

	}

	private void setTop() {
		tvBack.setText("");
		tvTitle.setText("参与成员");
		tvSearch.setVisibility(View.GONE);
	}

	private void setAdapter() {

		mAdapter = new CommonAdapter<ZoneHaoYouBean>(this, dataList,
				R.layout.item_join_member_read) {
			@Override
			public void convert(final ViewHolder holder, final ZoneHaoYouBean t) {
				holder.setText(R.id.tvMemberName, t.getName());
			}
		};
		mainList.setAdapter(mAdapter);
	}

	@OnClick({ R.id.tvBack })
	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.tvBack:
			finish();
			break;
		default:
			break;
		}
	}

}
